package main

import (
	"fmt"
	"github.com/atotto/clipboard"
	"os/exec"
)

var sumText = string(256)

func RunGitCommand(name string, arg ...string) (string, error) {
	//gitpath := "D:\\wwwroot\\easy-collabora"

	cmd := exec.Command(name, arg...)
	//cmd.Dir = gitpath // 指定工作目录为git仓库目录
	//cmd.Stderr = os.Stderr
	msg, err := cmd.CombinedOutput() // 混合输出stdout+stderr
	cmd.Run()

	// 报错时 exit status 1
	//fmt.Printf(string(msg))
	sumText += string(msg)
	return string(msg), err
}

func main() {
	RunGitCommand("git", "log", "--oneline", "--since=1.days")
	fmt.Printf(sumText + "[已复制到剪贴板]")
	clipboard.WriteAll("我今天完成的任务是：" + sumText)
}
